//
//  ExperienceDetailsViewController.m
//  GOGOTravel
//
//  Created by dllo on 16/1/24.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "ExperienceDetailsViewController.h"

@interface ExperienceDetailsViewController ()<UIWebViewDelegate>
@property (nonatomic, retain) UIWebView *web;
@property (nonatomic, retain) UIView *view1;
@property (nonatomic, retain) UIActivityIndicatorView *activity;
@end

@implementation ExperienceDetailsViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)dealloc{
    [_url release];
    [_title1 release];
    [_web release];
    [_view1 release];
    [_activity release];
    [super dealloc];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    if ([_title1 isEqualToString:@""]) {
        
        self.navigationItem.title = @"体验详情";
    }else{
        self.navigationItem.title = _title1;
    }
    
    
    [self initWeb];
    
    [self setItem];
    
    self.view1 = [[UIView alloc] initWithFrame:self.view.bounds];
    
    _view1.backgroundColor = [UIColor blackColor];
    _view1.alpha = 0.5;
    _view1.tag = 1000;
    [self.view addSubview:_view1];
    
    [_view1 release];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.9 green:0.29 blue:0.44 alpha:1];
   
    
    
}


/** item方法 */

- (void)itemAction:(UIBarButtonItem *)item{
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
}


/** 设置左边item */
- (void)setItem{
    
    UIImage *image = [UIImage imageNamed:@"iconfont-jiantouzuo.png"];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(itemAction:)];
    
    self.navigationItem.leftBarButtonItem = item;
    
    [item release];
    
}

- (void)webViewDidStartLoad:(UIWebView *)webView{
    
    self.activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    
   
    _activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
    
    [_view1 addSubview:_activity];
    _activity.center = _view1.center;
    [_activity release];
    
    [_activity startAnimating];
    
    
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    [_view1 removeFromSuperview];
    [_activity stopAnimating];
}

- (void)initWeb{
    
    self.web = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    [self.view addSubview:_web];
    _web.delegate = self;
    [_web loadRequest:[NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
    
    [_web release];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
